package com.qidian.common;

public abstract class TableMeta 
{
	// 消息表
	public static String table_message = "message" ;
	public static String column_msg_id = "msgId" ;
	public static String column_user_id = "userId" ;
	public static String column_client_id = "clientId" ;
	public static String column_ip = "ip" ;
	public static String column_port = "port" ;
	public static String column_interval = "interval_second" ;
	public static String column_receive_time = "recvTime" ;
	public static String column_answer_time = "answerTime" ;
	public static String column_request_time = "requestTime" ;
	public static String column_relative_path = "relativePath" ;
	public static String column_status = "status" ;
	public static String column_answer = "answer" ;
	public static String column_game_type = "gameType" ;
	public static String column_game_type_id = "gameTypeId" ;
	public static String column_content = "content" ;
	public static String column_content_type = "content_type" ;
	public static String column_return_user_id = "returnUserId" ;


	// 开发者用户表，记录用户的点数、已用点数
	public static String table_user = "user" ;
	public static String column_user_name = "userName" ;
	public static String column_password = "password" ;
	public static String column_point = "point" ;
	public static String column_point_used = "usedPoint" ;
	public static String column_QQ = "qq" ;
	public static String column_email = "email" ;
	public static String column_zhifubao = "zhifubao" ;
	public static String column_user_type = "userType" ;
	public static String column_return_point = "returnPoint" ;
	public static String column_return_ratio = "returnRatio"  ;
	
	// 客户端表，记录答题客户端的答题总数、错题数
	public static String table_client = "client" ;
	public static String column_client_user_name = "userName" ;
	public static String column_client_password = "password" ;
	public static String column_answer_count =  "answerCount" ;
	public static String column_wrong_count = "wrongCount" ;	
	public static String column_name = "name" ;
	public static String column_phone = "phone" ;
	public static String column_local_size = "localSize" ;
	public static String column_msg_type = "msgType" ;
	public static String column_work_time_start = "workTimeStart" ;
	public static String column_work_time_end = "workTimeEnd" ;
	
	// 项目类型表，记录不同项目类型的消息所消耗的单位点数
	public static String table_game_type = "gameType" ;
	public static String column_point_per = "pointUnit" ;
	public static String column_point_worker = "pointWorker" ;
	public static String column_game_description = "gameDescription" ;
	public static String column_answer_type = "answerType" ;
	public static String column_min_interval = "minInterval" ;
	public static String column_answer_length = "answerLen" ;
	public static String column_trans_on = "transOn" ;
	public static String column_difficulty = "difficulty" ;
	
	// 帐户表，记录用户的点数、已用点数
	public static String table_account = "account" ;
	public static String column_account_id = "accountId" ;
	public static String column_mask_code = "maskCode" ;
	public static String column_birth_time = "birthTime" ;
	public static String column_last_time = "lastTime" ;
	public static String column_valid_time = "validTime" ;
	public static String column_send_count = "sendCount" ;
	public static String column_report_count = "reportCount" ;
	public static String column_first_time = "firstTime" ;
	
	// 充值卡号表，记录卡号、点数、是否已用、生成者、生成时间、使用时间
	public static String table_recharge_card = "rechargeCard" ;
	public static String column_recharge_code = "rechargeCode" ;
	public static String column_is_used = "isUsed" ;
	public static String column_used_time = "usedTime" ;
	
	// 日志表，记录充值、子账号合并记录
	public static String table_logger = "logger" ;
	public static String column_cur_time = "curTime" ;
	public static String column_operation = "operation";// 操作类型
	public static String column_opera_A = "operaA" ;	// 操作数A
	public static String column_opera_B = "operaB" ;	// 操作数B
	public static String column_opera_C = "operaC" ;	// 操作数C
	public static String column_operator = "operator" ; // 操作人
	
	// 客户端统计表，记录每天的统计值
	public static String table_stastic_client = "stasticClient" ;
	public static String column_day = "day" ;
	public static String column_answer_count_yesterday = "answerCountYesterday" ;
	public static String column_wrong_count_yesterday = "wrongCountYesterday" ;
	public static String column_point_yesterday = "pointYesterday" ;
	
	public static String create_logger_table = "create table if not exists " + table_logger + "("+
			column_cur_time + " bigint primary key," +
			column_operation + " varchar(64) ," +
			column_opera_A + " varchar(64), " +
			column_opera_B + " varchar(64), " + 
			column_opera_C + " varchar(64), " + 
			column_operator + " varchar(64)) " ; 
	
	// 建表语句
	public static String create_message_table = "create table if not exists " + table_message+"(" +
			column_msg_id+" bigint primary key," +
			column_account_id+" bigint ," +
			column_client_id+" bigint ," +
			column_ip+" varchar(20) ,"+
			column_port+" int ,"+
			column_interval+" int ,"+
			column_receive_time+" bigint ,"+
			column_answer_time+" bigint ,"+
			column_request_time+" bigint ,"+
			column_relative_path+" varchar(255) ,"+
			column_status+" int ,"+
			column_answer+" varchar(20),"+
			column_game_type+" int , "+
			column_content + " blob,"+
			column_content_type + " varchar(20)," +
			column_user_id	+	" bigint,"+
			column_point + " int default 0,"+
			column_return_user_id + " bigint default 0)";
	
	public static String create_user_table = "create table if not exists " + table_user+"(" +
			column_user_id+" bigint primary key auto_increment," +
			column_user_name+" varchar(20) not null," +
			column_password+" varchar(20) ," +
			column_point+" int not null default 0,"+
			column_point_used+" int not null default 0," +
			column_birth_time +	" bigint default 0," +
			column_last_time +	" bigint default 0," +
			column_status+" int default 0," +
			column_QQ+" varchar(12)," +
			column_email+" varchar(32),"+
			column_zhifubao +" varchar(32),"+
			column_phone + " varchar(16),"+
			column_user_type + " int default 0,"+
			column_return_point+" double(20,2) default 0.00,"+
			column_return_ratio+" double(20,3) default 0.00 )" ;
	
	public static String create_client_table = "create table if not exists " + table_client+"(" +
			column_client_id+" bigint primary key auto_increment," +
			column_client_user_name+" varchar(20) unique not null ,"+
			column_client_password+" varchar(20) ,"+
			column_answer_count+" int not null default 0,"+
			column_wrong_count+" int not null default 0,"+
			column_point+ " double(20,2) not null default 0,"+
			column_status+" int default 0," +
			column_name+" varchar(10)," +
			column_phone+	" varchar(16)," +
			column_zhifubao+" varchar(32)," +
			column_work_time_start+	" int default 0," +
			column_work_time_end+ " int default 24)";
	
	public static String create_game_type_table ="create table if not exists " + table_game_type+"(" +
			column_game_type_id+" bigint primary key," +		
			column_game_type+" int ," +
			column_point_per+" int not null," +
			column_point_worker+" int not null," +
			column_game_description+" varchar(32) not null," +
			column_min_interval+" varchar(16) not null ," +
			column_answer_type+" int ," +
			column_answer_length+" int default 1," +
			column_status+" int default 0,"+
			column_trans_on+" int default 1,"+
			column_difficulty+" double(20,3) default 1.0 )";
	
	public static String create_account_table = "create table if not exists " + table_account+ "(" +
			column_account_id + " bigint primary key auto_increment,"+
			column_mask_code + " varchar(40) unique not null," + 
			column_point+" int default 0,"+
			column_point_used+" int default 0,"+
			column_user_id + " bigint not null references " + table_user+"("+column_user_id+")," +
			column_last_time+" bigint default 0,"+
			column_birth_time+" bigint default 0," +
			column_valid_time+" bigint default 0," +
			column_status + " int default 0," +
			column_send_count + " int default 0," +
			column_report_count + " int default 0,"+
			column_first_time +" bigint default 0)" ;
			//+column_isMainAccount + " bool )";
	
	public static String create_recharge_card_table = "create table if not exists " + table_recharge_card+"("+
			column_recharge_code + " char(32) primary key ," +
			column_point + " int default 0," +
			column_is_used + " int default 0,"+
			column_user_id + " bigint default 0 ," +
			column_birth_time + " bigint default 0," +
			column_valid_time + " bigint default 0," +
			column_used_time + " bigint default 0,"+
			column_status + " int default 0)";
	
	public static String create_stastic_client_table = "create table if not exists " + table_stastic_client+"("+
			column_day+" date,"+
			column_client_id+" bigint, "+
			column_answer_count+" int not null default 0,"+
			column_wrong_count+" int not null default 0,"+
			column_point+ " double(20,2) not null default 0,"+
			column_answer_count_yesterday+" int not null default 0,"+
			column_wrong_count_yesterday+" int not null default 0,"+
			column_point_yesterday+ " double(20,2) not null default 0)";
	
	public static void main(String[] args)
	{
		System.out.println(TableMeta.create_message_table) ;
		System.out.println(";") ;
		System.out.println(TableMeta.create_user_table);
		System.out.println(";") ;
		System.out.println(TableMeta.create_client_table);
		System.out.println(";") ;
		System.out.println(TableMeta.create_game_type_table);
		System.out.println(";") ;
		System.out.println(TableMeta.create_account_table);
		System.out.println(";") ;
		System.out.println(TableMeta.create_recharge_card_table);
//		System.out.println(";") ;
//		System.out.println(TableMeta.clear_recharge_card_table);
	}
	
}
